#include "call_global.h"

If_Contacts_Contact_Para_t ContactPara;

VOID Mo_From_Framework(VOID)
{
    INT8 tmp[]   = "10086";
    INT8 *Number = (INT8 *)Hal_Mem_Alloc(sizeof(tmp));

    Hal_Mem_Copy(Number, tmp, sizeof(tmp));
    Call_Framework_Voice_Call_Req(Number);
}

VOID Mo_From_Framework_Call_Waiting(VOID)
{
    INT8 tmp[]   = "13478407721";
    INT8 *Number = (INT8 *)Hal_Mem_Alloc(sizeof(tmp));

    Hal_Mem_Copy(Number, tmp, sizeof(tmp));
    Call_Framework_Voice_Call_Req(Number);
}

VOID Mo_From_Contact(VOID)
{
    INT8 *TmpName;
    INT8 *TmpNumber;

    TmpName = (INT8 *)Hal_Mem_Alloc(strlen("User1") + 1);
    Hal_Mem_Copy(TmpName, "User1", strlen("User1") + 1);

    TmpNumber = (INT8 *)Hal_Mem_Alloc(strlen("10086") + 1);
    Hal_Mem_Copy(TmpNumber, "10086", strlen("10086") + 1);
    Contacts_Call_Req(TmpName, TmpNumber);
}

VOID MT_From_Idle(VOID)
{
    MMI_Modem_Call_Response_Clip_t *Clip;
    INT8                           Number[] = "13477000077";

    Clip         = (MMI_Modem_Call_Response_Clip_t *)Hal_Mem_Alloc(sizeof(MMI_Modem_Call_Response_Clip_t));
    Clip->number = (INT8 *)Hal_Mem_Alloc(strlen(Number) + 1);
    Hal_Mem_Set(Clip->number, 0, strlen(Number) + 1);
    Hal_Mem_Copy(Clip->number, Number, strlen(Number));

    MMI_Modem_Call_Response_Ring(MMI_MODEM_SIM_2, 1);
    MMI_Modem_Call_Response_Clip(MMI_MODEM_SIM_2, 1, Clip);
// MMI_Modem_Call_Response_Ring(MMI_MODEM_SIM_2, 2);
}

VOID Dummy_Over(VOID *pDesc)
{
    INT8             TempChar[20];
    UI_Status_Desc_t *pTmpDesc
        = (UI_Status_Desc_t *)pDesc;

    /* set called name */
    sprintf(TempChar, "%s", "test over");
    lv_label_set_text(pTmpDesc->ContLabel.Label, TempChar);
    Hal_Mem_Check_End();
}

VOID Display_Dummy(VOID)
{
    Nav_Func_List_t  FuncList;
    UI_Status_Desc_t *pDesc;

    FuncList.OnShow         = (Void_P_Func_t)UI_Status_Create;
    FuncList.OnHide         = NULL;
    FuncList.OnCreate       = NULL;
    FuncList.OnDestroy      = NULL;
    FuncList.OnSaveState    = NULL;
    FuncList.OnRestoreState = Dummy_Over;

    pDesc = (UI_Status_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Status_Desc_t));
    memset(pDesc, 0, sizeof(UI_Status_Desc_t));

    pDesc->ContLabel.TxtId    = PHONE_TEXT_ID_OK;
    pDesc->ContLabel.TxtAlign = LV_LABEL_ALIGN_LEFT;
    pDesc->ContLabel.SymbolId = SYMBOL_SIM1;
    pDesc->ContLabelAlign     = LV_ALIGN_IN_TOP_LEFT;
    pDesc->KeyFunc            = NULL;

    Nav_Forward(ACT_ID_ANY, ACT_ID_CALL_BUSY, &FuncList, pDesc);
}

extern VOID Call_Init_Req(VOID);

VOID Call_Test_Main(VOID)
{
    hal_rtc_t time;

    Hal_Init();
    UI_Log_Out(1, 1, "call UT %d", 1);
    UI_Log_Out(1, 1, "call UT1 %d\n", 1);
    UI_Log_Out(1, 1, "call UT2 %d\n", 1);
    UI_Common_Test_Main();
    UI_Normal_Common_init();
    Call_Init_Req();
    Display_Dummy();

    Hal_Mem_Check_Start();
    Mo_From_Framework_Call_Waiting();
// Mo_From_Framework();
// MT_From_Idle();
// Mo_From_Contact();
}

VOID CallLog_Call_Add_Log(NV_Call_Log_Data_t *Data)
{
    UI_Log_Out(UI_SUB_MODULE_CALL, UI_LOG_LEVEL_TRACE_1, "%s\n", __FUNCTION__);
    Hal_Mem_Free(Data);
}

/**
 * Indicates to status bar when there is a calling or incoming call.
 * param (in) call: false:no call, true:has call
 * param (in) MissedCall: false:not missed call, true:missed call
 * return VOID
 */
VOID Framework_Call_Calling_Or_Incoming_Ind(BOOL call, BOOL MissedCall)
{
    UI_Log_Out(UI_SUB_MODULE_CALL, UI_LOG_LEVEL_TRACE_1, "%s\n", __FUNCTION__);
}

/**
 * Indicates to status bar that the loudspeaker is on/off
 * param (in) loudspeaker:  false:loudspeaker off, true:loudspeaker  on
 * return VOID
 */
VOID Framework_Call_Loudspeaker_Ind(BOOL loudspeaker)
{
    UI_Log_Out(UI_SUB_MODULE_CALL, UI_LOG_LEVEL_TRACE_1, "%s\n", __FUNCTION__);
}

/**
 * Menu main entrance
 * param (in) VOID
 * return  VOID
 */
VOID Framework_Call_Menu_Main(VOID)
{
    UI_Log_Out(UI_SUB_MODULE_CALL, UI_LOG_LEVEL_TRACE_1, "%s\n", __FUNCTION__);
}

/**
 * Get parameters associated with the phone number
 * param (in) Number: INT8*
 * param (out) ContactPara: If_Contacts_Contact_Para_t *
 * return  VOID
 */
VOID Contacts_Get_Contact_Para_Req(INT8 *Number, If_Contacts_Contact_Para_t *ContactPara)
{
    static UINT8 swap = 0;

    if ((swap++) % 2)
    {
        Hal_Mem_Copy(ContactPara->Name, "user2", strlen("user2") + 1);
    }
    else
    {
        Hal_Mem_Copy(ContactPara->Name, "user1", strlen("user1") + 1);
    }

    ContactPara->ToneIndex  = 1;
    ContactPara->NumScrnFlg = FALSE;
}

/**
 * Select contact in contacts APP, don`t display option button
 * If contact is empty, display warning and return to source APP
 * param (in) Type: IF_CONTACTS_SEL_CONTACT_TYPE
 * return  VOID
 */
VOID Contacts_Select_Contact_Req(IF_CONTACTS_SEL_CONTACT_TYPE Type)
{
    UI_Log_Out(UI_SUB_MODULE_CALL, UI_LOG_LEVEL_TRACE_1, "%s\n", __FUNCTION__);
}

/**
 * get dual standby status
 * param (in) ServiceType: IF_SETTING_SERVICE_TYPE
 * return  UINT8: IF_SETTING_DEFAULT_SIM
 */
UINT8 Setting_Get_Default_Sim_Req(IF_SETTING_SERVICE_TYPE ServiceType)
{
    UI_Log_Out(UI_SUB_MODULE_CALL, UI_LOG_LEVEL_TRACE_1, "%s\n", __FUNCTION__);
    return(0);
}

/**
 * ask tone setting module to play tone/vibrating
 * param (in) simId: MMI_MODEM_SIM_ID
 * return  void
 */
VOID Setting_Play_Tone_Req(If_Setting_Play_Tone_t *SettingPlayTone)
{
    UI_Log_Out(UI_SUB_MODULE_CALL, UI_LOG_LEVEL_TRACE_1, "%s\n", __FUNCTION__);
    UI_Log_Out(UI_SUB_MODULE_CALL, UI_LOG_LEVEL_TRACE_1, "Play Tone: Sim %d, type %d, Ctrl %d, ToneIndex %d\n", SettingPlayTone->SimId, SettingPlayTone->ToneType, SettingPlayTone->PlayCtrl, SettingPlayTone->SpecToneIndex);

    Hal_Mem_Free(SettingPlayTone);
}
